package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResPicture;
import com.hmkj.entity.ErspResResponse;

public class ErspResResponseDao extends JActiveTable {
	public ErspResResponseDao() {
		this.setDBTableName("ersp_res_response");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("res_id", "res_id", ActiveField.ftString, 36));
		AddField(new JActiveField("org_id", "org_id", ActiveField.ftString, 36));
		AddField(new JActiveField("user_id", "user_id", ActiveField.ftString, 36));
		AddField(new JActiveField("resp_result", "resp_result", ActiveField.ftString, 2));
		AddField(new JActiveField("resp_result_content", "resp_result_content", ActiveField.ftString, 500));
		
		
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
        setDbKeyFields("id");
	}

	public int add(ErspResResponse vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("org_id", vo.getOrg_id());
		setFieldValue("user_id", vo.getUser_id());
		setFieldValue("resp_result", vo.getResp_result());
		setFieldValue("resp_result_content", vo.getResp_result_content());
		
		return DBManager.ExecSQL(this.getSQL());
	}

	public String getSQL(ErspResResponse vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("org_id", vo.getOrg_id());
		setFieldValue("user_id", vo.getUser_id());
		setFieldValue("resp_result", vo.getResp_result());
		setFieldValue("resp_result_content", vo.getResp_result_content());
		return this.getSQL();
	}
}
